package com.xuchao.rabbit.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @Author xuchao
 * @Date:2023/6/6 16:57
 * @description RabbitMQ创建线程工具类
 * @Version 1.0
 */
public class RabbitMqUtils {
    //得到一个连接的 channel
    public static Channel getChannel() throws Exception{
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //工厂ip 连接RabbitMQ队列
        factory.setHost("39.107.53.243");
//        factory.setPort(5672);
        //用户名
        factory.setUsername("zxc");
        //密码
        factory.setPassword("Zxcq1w2E#R$...");
        //创建连接
        Connection connection = factory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();
        return channel;
    }
}